-
Notifications
You must be signed in to change notification settings - Fork 63
fix: add tests for raw RSA keyring node #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
}) | ||
|
||
it('Precondition: RsaKeyringNode needs identifying information for encrypt and decrypt.', () => { | ||
// @ts-ignore Typescript is trying to save us. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is typescript saving us from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typescript knows that this function should be called with a keyNamespace
and a keyName
, so it will complain. But JS does not have this protection... So to test that this will indeed throw, I need TypeScript to be quite and not complain about calling the function incorrectly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
const suite = new NodeAlgorithmSuite(AlgorithmSuiteIdentifier.ALG_AES256_GCM_IV12_TAG16_HKDF_SHA256) | ||
const material = new NodeEncryptionMaterial(suite) | ||
const test = await keyring.onEncrypt(material) | ||
expect(test.hasValidKey()).to.equal(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this compare the type that is returned to be true? Or will any true value returned from this function pass this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.chaijs.com/api/bdd/#method_equal
it is ===
. The issue is that the udk should be random, so there is not too much to test. Given that I pull the udk below maybe this has no value.
Want me to pull it out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No i was trying to understand JS a little better.
Adding tests for raw RSA Keyring node
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.